package com.rdxer.api;

import com.rdxer.core.entity.Result;
import com.rdxer.core.entity.StatusCode;
import com.rdxer.core.security.AppUserDetails;
import com.rdxer.dataview.AnswerSheetDV;
import com.rdxer.dataview.PaperGradeDV;
import com.rdxer.model.AnswerSheet;
import com.rdxer.model.Paper;
import com.rdxer.service.GradeService;
import com.rdxer.service.PaperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * departmentManagement
 */
@RestController
@CrossOrigin
@RequestMapping("/grade")
public class GradeApi {

    @Autowired
    private GradeService service;
    @Autowired
    private PaperService paperService;


    @GetMapping("/paper")
    public Result<List<PaperGradeDV>> paper() {
        return new Result<>(true, StatusCode.OK, "查询成功", service.findAllPaperGradeDVByUserId(AppUserDetails.getCurrent().account.getId()));
    }
    @GetMapping("/paper/{paperId}")
    public Result<PaperGradeDV> paper(@PathVariable String paperId) {
        return new Result<PaperGradeDV>(true, StatusCode.OK, "查询成功",service.findPaper(paperId));
    }


    @GetMapping("/answerSheet/ByPaper/{paperId}")
    public Result<List<AnswerSheetDV>> getByByPaperId(@PathVariable String paperId){
        return new Result(true, StatusCode.OK,"查询成功",service.getAnswerSheetDVListByPaper(paperId));
    }
}
